/**
 * 获取元素信息
 * @param {String | Array} element 元素名
 * @param {Object} that  vm实例
 * @return {Object} 返回元素信息
 */
export function getEleInfo(element, that) {
	return new Promise((resolve, reject) => {
		let query = uni.createSelectorQuery().in(that);
		setTimeout(async () => {
			if (Array.isArray(element)) {
				for (let i = 0; i < element.length; i++) {
					await query.select(element[i]).boundingClientRect();
				}
			} else {
				query.select(element).boundingClientRect();
			}
			query.exec(res => {
				if (!res || !res[0]) {
					reject(res);
				}
				if (res.length == 1) {
					resolve(res[0]);
				} else {
					resolve(res);
				}
			});
		});
	});
}